import React, { Component } from 'react';
import './Login.scss'


class Login extends Component {
    constructor(props) {
        super(props);
        this.state = {
            phone: "",
            pass: "",
            isRead: false
        }
    }
    handleChange(e) {
        this.setState({
            [e.target.name]: ((e.target.type == 'checkbox' || e.target.type == 'radio') ? e.target.checked : e.target.value)
        }, () => {
            console.log(this.state)
        }
        )
    }
    login() {
        var newState = JSON.parse(JSON.stringify(this.state));
        delete newState.isRead;
        console.log(newState);
    }


    render() {
        return (
            <div className='login'>
                <input type="text" name='phone' value={this.state.phone} onChange={(e) => { this.handleChange(e) }} placeholder='输入手机号' />
                <input type="password" name='pass' value={this.state.pass} onChange={(e) => { this.handleChange(e) }} placeholder='输入密码' />
                {/* <input type="checkbox" name='isRead' checked={this.state.isRead} onChange={(e) => { this.handleChange(e) }} /> */}
                <div className='btn'>
                    <button onClick={() => { this.login() }}>登录</button>
                </div>
                <button className='zhuce'>注册</button>
            </div>
        );
    }
}

export default Login;